package org.jmhome.blog.model;

import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.OrderBy;
import javax.persistence.Table;

@Entity
@Table(name = "BOARD_CATEGORY")
@NamedQueries({
		@NamedQuery(name = "org.jmhome.blog.model.Category", query = "from Category as category where categoryCode = :categoryCode"),
		@NamedQuery(name = "org.jmhome.blog.model.Category@Categories", query = "from Category as category") })
public class Category {

	@Id
	private String categoryCode;

	private String categoryName;

	private String categoryUrl;

	@OneToMany(targetEntity = Board.class, mappedBy = "category", cascade = CascadeType.ALL, fetch = FetchType.LAZY)
	@OrderBy("boardSeq desc")
	private List<Board> board;

	/*
	 * @ManyToOne
	 * 
	 * @JoinColumn(name = "email") private User user;
	 */

	public Category() {
		super();
	}

	public Category(String categoryCode, String categoryName, String categoryUrl) {
		super();
		this.categoryCode = categoryCode;
		this.categoryName = categoryName;
		this.categoryUrl = categoryUrl;
	}

	/**
	 * @return the categoryCode
	 */
	public String getCategoryCode() {
		return categoryCode;
	}

	/**
	 * @param categoryCode
	 *            the categoryCode to set
	 */
	public void setCategoryCode(String categoryCode) {
		this.categoryCode = categoryCode;
	}

	/**
	 * @return the categoryName
	 */
	public String getCategoryName() {
		return categoryName;
	}

	/**
	 * @param categoryName
	 *            the categoryName to set
	 */
	public void setCategoryName(String categoryName) {
		this.categoryName = categoryName;
	}

	/**
	 * @return the categoryUrl
	 */
	public String getCategoryUrl() {
		return categoryUrl;
	}

	/**
	 * @param categoryUrl
	 *            the categoryUrl to set
	 */
	public void setCategoryUrl(String categoryUrl) {
		this.categoryUrl = categoryUrl;
	}

	/**
	 * @return the board
	 */
	public List<Board> getBoard() {
		return board;
	}

	/**
	 * @param board
	 *            the board to set
	 */
	public void setBoard(List<Board> board) {
		this.board = board;
	}

	/**
	 * @return the user
	 */
	/*
	 * public User getUser() { return user; }
	 *//**
	 * @param user
	 *            the user to set
	 */
	/*
	 * public void setUser(User user) { this.user = user; }
	 */

}
